Home:ALL Converter>Split full searchterm in single terms SQL

Split full searchterm in single terms SQL

Ask Time:2018-11-07T22:41:12         Author:Felix Kunz

Json Formatter

I'm working on a small FAQ site with a Searchfunction

Right now i use SQL and search for the right entry like this:

<form action="search.php" method="get">
  <label>
    Search
    <input type="text" name="keywords" autocomplete="off">
  </label>

  <input type="submit" value="Search">
</form>

<?php
require_once '../db/connect.php';

if (isset($_GET['keywords'])&& empty($_GET['keywords']) === false) {
  // code...
   $keywords = $connection->real_escape_string($_GET['keywords']);

   $query = $connection->query("
    SELECT question, answer
    FROM FAQ
    WHERE tags LIKE '%{$keywords}%'

   ");

   ?>

When i search for "WLAN" it shows the entry where i have "Wlan, Connection, ..." in the tags. When i search for Connection it shows the same entry. Great so far! But when i search for "Connection with WLAN" it doesn't work... obviously. Is there an easy method to implement this?

It would be something like '%{$keywords}%' where i can say it just has to be equal to some part of the string.

Any ideas?

Author:Felix Kunz,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/53191688/split-full-searchterm-in-single-terms-sql
yy